<template>
  <div class="paginationArea">
    <el-pagination
      background
      :current-page="pageInfo.currentPage"
      :page-sizes="pageSizes"
      :page-size="pageInfo.pageSize"
      :layout="layout"
      :total="pageInfo.total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  name: 'RailPagination',
  components: {},
  props: {
    pageInfo: {
      type: Object,
      default() {
        return {
          currentPage: 1,
          pageSize: 10,
          total: 0
        }
      }
    },
    pageSizes: {
      type: Array,
      default() {
        return [10, 15, 20]
      }
    },
    layout: {
      type: String,
      default: 'total,  prev, pager, next, sizes, jumper'
    }
  },
  data() {
    return {

    }
  },
  computed: {},
  created() {},
  mounted() {},
  methods: {
    handleSizeChange(val) {
      this.pageInfo.pageSize = val
      this.$emit('pagination', {
        currentPage: this.pageInfo.currentPage,
        pageSize: val
      })
    },
    handleCurrentChange(val) {
      this.pageInfo.currentPage = val
      this.$emit('pagination', {
        currentPage: val,
        pageSize: this.pageInfo.pageSize
      })
    }
  }
}

</script>
<style lang='scss' scoped>
  .paginationArea {
    display: flex;
    justify-content: flex-end;
    padding: 15px 0;
  }

</style>
